const mongoose = require("../config/db");
const UserSchema = mongoose.Schema({
  username: {
    type: String,
    required: true,
    unique: true,
    minlength: 2,
    maxlength: 12
  },
  password: {
    type: String,
    require: true
  },
  realname: {
    type: String,
    required: true,
    minlength: 2,
    maxlength: 12
  },
  tel: {
    type: String,
    default: ''
  },
  email: {
    type: String,
    default: ''
  },
  state: {
    type: Boolean,
    default: true
  },
  role: {
    type: String,
    default: "用户"
  },
  head: {
    type: String,
    default: "/img/head.png"
  },
  create_time: {
    type: Date,
    default: Date.now
  },
  update_time: {
    type: Date,
    default: Date.now
  }
},
  {
    versionKey: false,
    timestamps: { createdAt: "create_time", updatedAt: "update_time" }
  }
)
const UsersModel = mongoose.model("Users", UserSchema, "users");
module.exports = UsersModel;